#include <iostream>

int main()
{
    int school[7], mom[7];
    int max_hour = 0, the_worst_day = 0;
    for (int day = 0; day < 7; day++)
    {
        scanf("%d %d", &school[day], &mom[day]);
    }
    for (int day = 0; day < 7; day++)
    {
        int total = school[day] + mom[day];
        if (total > 8 && total > max_hour)
        {
            max_hour = total;
            the_worst_day = day + 1;
        }
    }
    printf("%d", the_worst_day);
    return 0;
}